#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    unordered_map<char,int>mp;
    for(int i=0;i<n;i++){
        mp[s[i]]++;
    }
    int sn=mp['S']+mp['s'];
    int hn=mp['h']+mp['H'];
    int an=mp['a']+mp['A'];
    int gn=mp['g']+mp['G'];
    int in=mp['i']+mp['I'];
    int nn=mp['n']+mp['N'];
    hn/=2;
    an/=2;
    int minn=min({nn,sn,hn,an,gn,in});
    cout<<minn;
    return 0;
}